/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package servlets;

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 *
 * @author Alex
 */
@WebServlet(name = "SellerAggiungiProdotto", urlPatterns = {"/SellerAggiungiProdotto"})
public class SellerAggiungiProdotto extends HttpServlet {

    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html");
        PrintWriter out = response.getWriter();
        HttpSession session = request.getSession(false);
        if(session.getAttribute("seller")==null)
            response.sendRedirect(request.getContextPath() + "/ErrorLoginServlet");
        
        String username=(String)session.getAttribute("username");


out.println("<!DOCTYPE html>"
+"<html>");

out.println("<head>"
+ "<link rel=\"stylesheet\" type=\"text/css\" href=\"css/bootstrap.css\"> ");
out.println("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\">");
out.println("<title>LANDINGBUYER Page</title>");
out.println("<meta name=\"generator\" content=\"WYSIWYG Web Builder 8 - http://www.wysiwygwebbuilder.com\">");
out.println("<style type=\"text/css\">");
out.println("</style>");
out.println("</head>");
out.println("<body>");
out.println("<div class=\"navbar  navbar-inverse nvbar-fixed-top\">" +
"<div class=\"navbar-inner\">" +
"<div class=\"container\">" +
 

"<a class=\"btn btn-navbar navbar-inverse nvbar-fixed-top \" data-toggle=\"collapse\" data-target=\".nav-collapse\">" +
"<span class=\"icon-bar\"></span>" +
"<span class=\"icon-bar\"></span>" +
"<span class=\"icon-bar\"></span>" +
"</a>" +
 


           " <ul class=\"nav\">" +
   " <li><a href=\"#\"></a></li>" +
   " <li class=\"active\">" +
   " <a href=\"#\">Aggiungi Prodotto</a>" +
   " </li>" +     
   " <li><a href=\"http://localhost:8084/PROGETTO_WEB_1/SellerLandingServlet\">Seller Page</a></li>"+
   " <li><a href=\"http://localhost:8084/PROGETTO_WEB_1/LogoutServlet\">Log Out</a></li>" +     
   " </ul>" +

"<div class=\"nav-collapse collapse\">" +

"</div>" +
 
"</div>" +
"</div> </div>");

out.println("<div id=\"wb_Text1\" style=\"position:absolute;left:84px;top:64px;\"> ");
out.println("<h2>Add Product</h2> </div>");

//  ---- FORM ----
out.println("  <form method=\"get\" class=\"form-horizontal\" action=\"SellerProdottoInDataBase\" style=\"position:absolute;left:84px;top:100px;\">\n" +
"    <br><br>\n" +
"<fieldset>   \n" +
"<div class=\"control-group\" >\n" +
"    <label class=\"control-label\" >Seller</label>\n" +
"    <div class=\"controls\">\n" +
"        <input type=\"text\" class=\"input-large\" name=\"seller\" value=\""+username+"\">\n" +
"    </div>\n" +
"</div>\n" +
"     \n" +
"<div class=\"control-group\">\n" +
"    <label class=\"control-label\">Product</label>\n" +
"    <div class=\"controls\">\n" +
"    <input type=\"text\" class=\"input-large\" name=\"product\" placeholder=\"Inserire il nome...\" onBlur=\"isALFABETIK(this)\">\n" +
//CONTROLLO STRINGA
        "     <script language=\"Javascript\">"+
"function isALFABETIK(obj) {"+

"if (!isNaN(obj.value)){"+
  "alert('Nel campo è possibile immettere solo caratteri alfabetici!');"+
  "obj.value=\"\";"+
  "obj.focus();}}"+

"</script>"+
//FINE
        "    </div>\n" +
"</div>\n" +
"\n" +
"<div class=\"control-group\">\n" +
"    <label class=\"control-label\">Quantity</label>\n" +
"    <div class=\"controls\">\n" +
"    <input type=\"text\" class=\"input-large\" name=\"quantity\" value=\"1\" onBlur=\"isNUM(this)\">\n"+
//CONTROLLO QUALITà
        "     <script language=\"Javascript\">"+
"function isNUM(obj) {"+

"if (isNaN(obj.value) || parseInt(obj.value)<0 || parseInt(obj.value) > 9999){"+
  "alert('Nel campo è possibile immettere solo numeri!');"+
  "obj.value=\"\";"+
  "obj.focus();}}"+

"</script>"+
//FINE


"    </div>\n" +
"</div>\n" +
"    \n" +
"<div class=\"control-group\">\n" +
"    <label class=\"control-label\">Category</label>\n" +
"    <div class=\"controls\">\n" +
"<select name=\"combobox\" >" +
"<option>Ortaggi</option>" +
"<option>Formaggi</option>" +
"<option>Frutta</option>" +
"<option>Agrumi</option>" +
"</select> " +
"    </div>\n" +
"</div>\n" +
"    \n" +    
"<div class=\"control-group\">\n" +
"    <label class=\"control-label\">UM</label>\n" +
"    <div class=\"controls\">\n" +
"    <input type=\"text\" class=\"input-large\" name=\"um\" value=\"Kg/euro\">\n" +
"    </div>\n" +
"</div>    \n" +
"    \n" +
"<div class=\"control-group\">\n" +
"    <label class=\"control-label\">Price</label>\n" +
"    <div class=\"controls\">\n" +
"    <input type=\"text\" class=\"input-large\" name=\"price\" placeholder=\"Inserire il prezzo...\" onBlur=\"isFLOAT(this)\">\n" +
//CONTROLLO PRICE
        " <script language=\"Javascript\">"+
"function isFLOAT(obj) {"+

"if (isNaN(obj.value) || parseFloat(obj.value)<0 || parseFloat(obj.value) > 9999){"+
  "alert('Nel campo è possibile immettere solo numeri!');"+
  "obj.value=\"\";"+
  "obj.focus();}}"+

"</script>"+
//FINE
        "    </div>\n" +
"</div>\n" +
"    \n" +


"        <input type=\"submit\" class=\"btn btn-success\" style=\"align: center\" name=\"aggiungi\" value=\"AggiungiProdotto\">   \n" +
"    </div>\n" +
"</fieldset>\n" +
"</form>");
if (session.getAttribute("problema")!= null)
out.println("    <div class=\"alert\">"
    +"<button type=\"button\" class=\"close\" data-dismiss=\"alert\">×</button>"
    +"<strong>Warning!</strong> Best check yo self, you're not looking too good."
    +"</div>");
    
out.println("</body>");
out.println("</html>");

    
    
    

//seller product quantity combobox um price
 
    
    }}

